package com.lwt.dao.base.dao.daoImpl;

import com.lwt.dao.base.BaseDao;
import com.lwt.dao.base.dao.GradeDao;
import com.lwt.pojo.Grade;

import java.util.List;

/**
 * @Author Li Weitong
 * @Date 2020/11/22 15:34
 */
public class GradeImpl extends BaseDao implements GradeDao {
    @Override
    public int addGradeInfo(Grade grade) {
        String sql = "insert into sm_grade values(?,?)";
        return update(sql,grade.getGradeId(),grade.getGradeName());
    }

    @Override
    public int deleteGradeById(Integer gradeId) {
        String sql = "delete from sm_grade where gradeId=?";
        return update(sql,gradeId);
    }

    @Override
    public int updateGrade(Grade grade) {
        String sql = "update sm_grade set gradeName=? where gradeId=?";
        return update(sql,grade.getGradeName(),grade.getGradeId());
    }

    @Override
    public List<Grade> queryGradeList() {
        String sql = "select gradeId,gradeName from sm_grade";
        return queryForList(Grade.class,sql);
    }
}
